package com.order.mapper;

import com.github.pagehelper.Page;
import com.order.annotation.AutoFill;
import com.order.dto.ConsumerPageQueryDTO;
import com.order.entity.User;
import com.order.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user where username = #{username}")
    User getByUsername(String username);

    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into user(name, username, password, phone, status,created_time,updated_time)" +
            "values" +
            "(#{name},#{username},#{password},#{phone},#{status},#{createdTime},#{updatedTime});")
    void insert(User user);


    Page<User> pageQuery(ConsumerPageQueryDTO consumerPageQueryDTO);

    void update(User user);

    /**
     * 根据Id查询客户信息
     * @param id
     * @return
     */
    @Select("select * from user where id = #{id}")
    User getById(long id);


    /**
     * 根据客户Id集合批量删除客户数据
     * @param ids
     * @return
     */

    void deleteByIds(List<Long> ids);


}
